module.exports   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 100

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 100
rs 8.2857
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
/*
2
 * @copyright Copyright (c) 2016 Julius Härtl <[email protected]>
3
 *
4
 * @author Julius Härtl <[email protected]>
5
 *
6
 * @license GNU AGPL version 3 or any later version
7
 *  
8
 *  This program is free software: you can redistribute it and/or modify
9
 *  it under the terms of the GNU Affero General Public License as
10
 *  published by the Free Software Foundation, either version 3 of the
11
 *  License, or (at your option) any later version.
12
 *  
13
 *  This program is distributed in the hope that it will be useful,
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 *  GNU Affero General Public License for more details.
17
 *  
18
 *  You should have received a copy of the GNU Affero General Public License
19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 *  
21
 */
22
23
24
module.exports = function(grunt) {
25
  'use strict';
26
27
	grunt.loadNpmTasks('grunt-contrib-concat');
28
	grunt.loadNpmTasks('grunt-contrib-watch');
29
	grunt.loadNpmTasks('grunt-contrib-jshint');
30
	grunt.loadNpmTasks('grunt-wrap');
31
	grunt.loadNpmTasks('grunt-karma');
32
	grunt.loadNpmTasks('grunt-phpunit');
33
34
	grunt.initConfig({
35
36
		meta: {
37
			pkg: grunt.file.readJSON('package.json'),
38
			version: '<%= meta.pkg.version %>',
39
			configJS: 'config/',
40
      buildJS: [
41
					'app/**/*.js',
42
					'controller/**/*.js',
43
					'filters/**/*.js',
44
					'directive/**/*.js',
45
					'service/**/*.js'
46
      ],
47
			productionJS: 'public/',
48
			testsJS: '../tests/js/'
49
		},
50
51
		concat: {
52
			options: {
53
				stripBanners: true
54
			},
55
			dist: {
56
				src: ['<%= meta.buildJS %>'],
57
				dest: '<%= meta.productionJS %>app.js'
58
			}
59
		},
60
61
		wrap: {
62
			app: {
63
				src: ['<%= meta.productionJS %>app.js'],
64
				dest: '<%= meta.productionJS %>app.js',
65
				option: {
66
					wrapper: [
67
						'(function(angular, $, oc_requesttoken, undefined){\n\n\'use strict\';\n\n',
68
						'\n})(angular, jQuery, oc_requesttoken);'
69
					]
70
				}
71
			}
72
		},
73
74
		jshint: {
75
			files: [
76
				'Gruntfile.js',
77
				'<%= meta.buildJS %>**/*.js',
78
				'<%= meta.testsJS %>**/*.js'
79
			],
80
			options: {
81
				jshintrc: '.jshintrc',
82
				reporter: require('jshint-stylish')
83
			}
84
		},
85
86
		watch: {
87
			concat: {
88
				files: ['<%=meta.buildJS%>'],
89
				options: {
90
					livereload: true
91
				},
92
				tasks: ['build']
93
			}
94
		},
95
96
		phpunit: {
97
			classes: {
98
				dir: '../tests/unit'
99
			},
100
			options: {
101
				bootstrap: '../tests/bootstrap.php',
102
				colors: true
103
			}
104
		},
105
106
		karma: {
107
			unit: {
108
				configFile: '<%= meta.testsJS %>config/karma.js'
109
			},
110
			continuous: {
111
				configFile: '<%= meta.testsJS %>config/karma.js',
112
				browsers: ['Firefox'],
113
				singleRun: true,
114
				reporters: ['progress']
115
			}
116
		},
117
	});
118
119
	// make tasks available under simpler commands
120
	grunt.registerTask('build', ['jshint', 'concat', 'wrap']);
121
	grunt.registerTask('js-unit', ['karma:continuous']);
122
123
};
124